﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace INSTA.BankApplication.DAL
{
    /// <summary>
    /// Attribute used to decorate properties in order to indicate
    /// the field of the database table to which they are mapped to.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class FieldAttribute : Attribute
    {

        /// <summary>
        /// Initializes a new instance of the <see cref="FieldAttribute"/> class.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        public FieldAttribute(string fieldName) : this(fieldName, false)
        {}

        /// <summary>
        /// Initializes a new instance of the <see cref="FieldAttribute"/> class.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="isPrimaryKey">if set to <c>true</c> [is primary key].</param>
        public FieldAttribute(string fieldName, bool isPrimaryKey)
        {
            FieldName       = fieldName;
            IsPrimaryKey    = isPrimaryKey;
        }


        /// <summary>
        /// Gets the name of the field.
        /// </summary>
        /// <value>The name of the field.</value>
        public string FieldName { get; set; }

        /// <summary>
        /// Gets a value indicating whether the decorated field 
        /// represents the mapped table's primary key.
        /// </summary>
        /// <value><c>true</c> if this instance is primary key; otherwise, <c>false</c>.</value>
        public bool IsPrimaryKey { get;  set; }

    }
}
